package com.shuoyue.ycgk.ui.shop.address;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.address.OrderAddressBean;

import java.util.List;

public class AddressSelectAdapter extends AppBaseQuickAdapter<OrderAddressBean> {
    public AddressSelectAdapter(@Nullable List<OrderAddressBean> data) {
        super(R.layout.item_select_address, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderAddressBean item) {
        helper.addOnClickListener(R.id.lay_all);
        helper.addOnClickListener(R.id.edit);
        helper.addOnClickListener(R.id.delete);
        helper.setText(R.id.name, item.getContact());
        helper.setText(R.id.phone, item.getPhone());
        helper.setText(R.id.address, item.getProvinceName() + item.getCityName() + item.getRegionName() + item.getAddress());
        helper.setGone(R.id.defaule, item.getIsDefault() == 1);
        helper.setBackgroundColor(R.id.lay_all, item.isSelect() ?
                ContextCompat.getColor(mContext, R.color.default_address_color)
                : ContextCompat.getColor(mContext, R.color.white));
        helper.setGone(R.id.line, item.isSelect());
    }
}
